package RadianceM.DistributionSystem.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @className: TokenInfo
 * @description: Token信息实体
 * @author: 小碗
 * @date: 2023-11-03 17:59:06
 */

@Data
@AllArgsConstructor
public class TokenInfo implements Serializable {
	private Long loginTime;
	private Long expireTime; // 过期时常
	private Long userId;
	private String userName;

	// 到期时间
	public Long overtime() {
		long overtime = this.getLoginTime() + 1000L * 60 * 60 *this.expireTime;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		System.out.println("正在检测用户:"+ userName+"的Token--->\t" +
				"本token登陆时间为:"+sdf.format(new Date(this.getLoginTime()))+"\t"+
				"\t失效时间为:"+ sdf.format(new Date(overtime)));
		return overtime;
	}
}
